# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/debian/.devcontainer/base.Dockerfile

# [Choice] Debian version: buster, stretch
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# ** [Optional] Uncomment this section to install additional packages. **
COPY sources.list /etc/apt/sources.list
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
#     && apt-get -y install --no-install-recommends <your-package-list-here>
RUN  apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends  xz-utils 
ADD nix.sh .
USER vscode
RUN /bin/bash nix.sh
USER root
COPY nix.conf  /etc/nix/nix.conf

USER vscode

WORKDIR /home/vscode/.vscode-server
ADD extensions.tar.gz .

ENV PATH="/home/vscode/.nix-profile/bin/:${PATH}"

RUN nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixpkgs-unstable nixpkgs
RUN nix-channel --update

# RUN nix-env -i gnumake binutils ncurses 
RUN nix-env -i gnumake ncurses
RUN nix-env -iA nixpkgs.ocamlPackages.merlin nixpkgs.clang_11
RUN nix-env -iA nixpkgs.llvm_11

RUN nix-env -i ocaml dune menhir ocamlbuild 
RUN nix-env -iA nixpkgs.ocamlPackages.findlib
RUN nix-env -iA nixpkgs.ocamlPackages.utop
RUN nix-env -iA nixpkgs.ocamlPackages.num

RUN nix-env -iA  binutils
RUN nix-env --set-flag priority 9 clang-wrapper-11.1.0


USER root

RUN  update-alternatives --install /home/vscode/.nix-profile/bin/g++ g++ /home/vscode/.nix-profile/bin/clang++ 100 && update-alternatives --install /home/vscode/.nix-profile/bin/gcc gcc /home/vscode/.nix-profile/bin/clang 100
ENV TZ=Asia/Shanghai